#include<stdio.h>

int main(void)
{
	int M,k,day=0,zheng;
	
	scanf("%d%d",&M,&k);
	
	while(M>=k)
	{
		zheng=M/k;
		day+=zheng*k;
		M=M%k+zheng;
	}
	
	day+=M;
	
	printf("%d",day);
	
	return 0;
}
